<?php

namespace App\Admin\Controllers\Game;

use App\Admin\Controllers\Controller;
use App\Admin\Filters\Game\GameGiftFilter;
use App\Admin\Models\Game\GameGift;
use App\Admin\Requests\Game\GameGiftRequest;
use App\Admin\Resources\Game\GameGiftResource;
use Illuminate\Http\Request;

class GameGiftController extends Controller
{
    public function index(GameGiftFilter $filter)
    {
        $gameGifts = GameGift::query()
            ->filter($filter)
            ->paginate();

        return $this->ok(GameGiftResource::collection($gameGifts));
    }

    public function create()
    {
        return $this->ok();
    }

    public function store(GameGiftRequest $request)
    {
        $inputs = $request->validated();
        $gameGift = GameGift::create($inputs);

        return $this->created(GameGiftResource::make($gameGift));
    }

    public function edit(Request $request, GameGift $gameGift)
    {
        return $this->ok(GameGiftResource::make($gameGift));
    }

    public function update(GameGiftRequest $request, GameGift $gameGift)
    {
        $inputs = $request->validated();
        $gameGift->update($inputs);

        return $this->created(GameGiftResource::make($gameGift));
    }

    public function destroy(GameGift $gameGift)
    {
        $gameGift->delete();
        return $this->noContent();
    }
}
